package com.itheima.leetcode.od.c.sort;

import java.util.*;

/**
 * <h3>机场航班调度</h3>
 */
public class AirportFlightScheduling {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 读取输入并按逗号分割
        String[] params = scanner.nextLine().split(",");

        // 自定义排序：先按前两个字符排序，再按剩余字符排序
        Arrays.sort(params, (a, b) -> {
            String a1 = a.substring(0, 2);
            String a2 = a.substring(2);
            String b1 = b.substring(0, 2);
            String b2 = b.substring(2);

            if (a1.equals(b1)) {
                return a2.compareTo(b2);
            }
            return a1.compareTo(b1);
        });

        // 用逗号连接并输出
        System.out.println(String.join(",", params));

        scanner.close();
    }
}